package java56_5;

public class Market {
	String supermarket;
	String marketaddress;

	Vip vipp[] = new Vip[200];

	public Market(String name, String ad) {
		this.supermarket = name;
		this.marketaddress = ad;
	}

	public void storeVipInfo(Vip v) {

		for (int i = 0; i < vipp.length; i++) {
			if (vipp[i] == null) {
				vipp[i] = v;
				return;
			}
		}
	}

	public void showVips() {
		for (int i = 0; i < vipp.length; i++) {
			if (vipp[i] == null) {
				return;
			}
			vipp[i].customersMs();
		}
	}

	public String exchange(String cardNo, int gifts) {

		for (int i = 0; i < vipp.length; i++) {
			if (vipp[i] != null && cardNo.equals(vipp[i].idNum)) {
				if (gifts == 1) {
					if (vipp[i].jifen >= 100) {
						vipp[i].jifen -= 100;
						return "纸巾一包";
					}
				} else if (gifts == 2) {
					if (vipp[i].jifen >= 400) {
						vipp[i].jifen -= 400;
						return "剃须刀一把";
					}
				} else if (gifts == 3) {
					if (vipp[i].jifen >= 1000) {
						vipp[i].jifen -= 1000;
						return "换炒锅一个";
					}
				}

			}

		}

		return null;
	}
}
